﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StableDiffusionTools.Utils
{
    public static class ProcessUtil
    {
        private delegate void LaunchProcessDelegate(string path, string args);
        private static LaunchProcessDelegate lauchProcess = new LaunchProcessDelegate(LaunchMethod);

        private static void LaunchMethod(string path, string args)
        {
            try
            {
                Process.Start(new ProcessStartInfo(path) { UseShellExecute = true, Arguments = args });
            }
            catch (Win32Exception) { }//There was an error in opening the associated file, ie not found.
        }

        public static void LaunchAsync(string path, string args = "")
        {
            lauchProcess.BeginInvoke(path, args, null, null);
        }
    }
}
